<template>
  <div id="makePlan">
    <!--<mt-header fixed title="鼎诚人寿重疾险" style="background-color: #ffffff; color: #000;"></mt-header>-->
      <div class="insureInfo">
        <section-head :sectionHeadDesc='insuredHeadDesc'></section-head>
        <sex-select v-on:getSex="getInsureSex" :sex="cSex"></sex-select>
        <age-select v-on:getAge="getInsureAge" :startDate="startInsuredDate" :endDate="endInsuredDate" :startAge="cAge"
                    :ageArray="ageInsuredArray" :age="cAge"></age-select>
        <health-insurance-select v-on:getHealthInsurance="getHealthInsurance"></health-insurance-select>
        <occ-picker v-on:getOcc="getOcc"></occ-picker>
        <section-head :sectionHeadDesc='policyHeadDesc' :showCheck="true" :checkDisable="pCheckDisable" :checked="pCheck" v-on:getChecked="getPolicyInfoChecked"></section-head>
        <sex-select v-show="showPolicyInfo" v-on:getSex="getPolicySex" :sex="pSex"></sex-select>
        <age-select  v-show="showPolicyInfo" v-on:getAge="getPolicyAge" :startDate="startPolicyDate" :endDate="endPolicyDate" :startAge="pAge"
                    :ageArray="agePolicyArray" :age="pAge"></age-select>
      </div>
      <div class="polSelect">
        <section-head :sectionHeadDesc='"险种选择"'></section-head>
        <pol-head v-if="polReset"
                  :calculateData="polTableData"
                  :selectPolData="usePolInfo"
                  v-on:getCheckStatus="getCheckStatus"
                  v-on:changePaymentPeriod="changePaymentPeriod"
                  v-on:calculate="getPremium"
                  :changePol="changePol">
        </pol-head>
      </div>
    <div class="coverInfo">
      <section-head :sectionHeadDesc='coverHeadDesc' :showCheck="true" :checkDisable="coverCheckDisable" :checked="coverCheck" v-on:getChecked="getCoverInfoChecked"></section-head>
      <div class="textContainer" v-show="showCoverInfo">
        姓名
        <div class="inputContainer">
          <jean-input :jeanInputPlaceHolder="'请输入姓名'" :width="'80px'" v-on:setInput="getCoverName"></jean-input>
        </div>
      </div>
      <sex-select v-show="showCoverInfo" v-on:getSex="getCoverSex" :sex="coverSex"></sex-select>
      <div class="textContainer" v-show="showCoverInfo">
        计划书标题
        <div class="inputContainer">
          <jean-input :jeanInputPlaceHolder="'请输入计划书标题'" :width="'150px'" v-on:setInput="getCoverTitle"></jean-input>
        </div>
      </div>
    </div>
    <div class="otherInfo">
      <div class="otherInfoContent" @click="showClause">
        <div class="iconContent">
          <i class="iconfont icon-documents otherInfoFont"></i>
        </div>
        <span>产品条款</span>
      </div>
      <div class="otherInfoContent" @click="showRate">
        <div class="iconContent">
          <i class="iconfont icon-advancemoney otherInfoFont"></i>
        </div>
        <span>产品费率</span>
      </div>
      <div class="otherInfoContent" @click="showRule">
        <div class="iconContent">
          <i class="iconfont icon-Insurance_policy otherInfoFont"></i>
        </div>
        <span>投保规则</span>
      </div>
    </div>
    <div class="bottom">
      <div class="premuimCount">
        <span class="premuimCountDesc">首年总保费</span>
        <p class="premuimCountNum" v-if="polTableData.sum">
          {{polTableData.sum.toString().split('.')[0]}}<span class="premuimCountNumSmall">.{{ polTableData.sum.toFixed(2).toString().split('.')[1] ? polTableData.sum.toFixed(2).toString().split('.')[1].substr(0, 2) : '00' }}元</span>
        </p>
      </div>
      <div class="buildPlan" @click="gotoShowPlan">
        生成计划书
      </div>
    </div>
    <ClauseList :data="clauseData" :show="clauseShow" v-on:clauseStatus="getClauseStatus"></ClauseList>
    <RateList :data="clauseData" :show="rateShow" v-on:rateStatus="getRateStatus"></RateList>
    <RuleList :data="clauseData" :show="ruleShow" v-on:ruleStatus="getRuleStatus"></RuleList>
  </div>
</template>

<script>
import SectionHead from '../components/sectionHead'
import SexSelect from '../components/sexSelect'
import AgeSelect from '../components/ageSelect'
import PolHead from '../components/polHead'
import HealthInsuranceSelect from '../components/healthInsuranceSelect'
import OccPicker from '../components/occPicker'
import {Indicator} from 'mint-ui'
import axios from 'axios'
import JeanInput from '../components/jeanInput'
import ClauseList from '../components/clauseList'
import RateList from '../components/rateList'
import RuleList from '../components/ruleList'

export default {
  name: 'makePlan',
  components: {RuleList, RateList, JeanInput, SectionHead, SexSelect, AgeSelect, PolHead, HealthInsuranceSelect, OccPicker, ClauseList},
  data () {
    return {
      insuredHeadDesc: '被保人信息',
      policyHeadDesc: '投保人信息(豁免相关)',
      coverHeadDesc: '封面信息',
      startInsuredDate: '',
      startPolicyDate: '',
      endInsuredDate: '',
      endPolicyDate: '',
      calculateObj: null,
      ageInsuredArray: [],
      agePolicyArray: [],
      cSex: 'M',
      cAge: '18',
      pSex: 'M',
      pAge: '30',
      coverSex: 'M',
      pCheckDisable: false,
      pCheck: true,
      coverCheckDisable: false,
      coverCheck: false,
      showPolicyInfo: true,
      showCoverInfo: false,
      paymentPeriodObj: {
        'pw': '趸交',
        'pf': '5年交',
        'pt': '10年交',
        'pfif': '15年交',
        'pytw': '20年交',
        'pfo': '4年交',
        'pn': '9年交',
        'pfot': '14年交',
        'pnt': '19年交',
        'pOne': '1年交',
        'ptnt': '29年交',
        'ptt': '30年交'
      },
      polTableData: {},
      allPolInfoData: null,
      usePolInfo: null,
      paymentPeriod: 'pytw',
      premium: 300000,
      polReset: true,
      changePol: false,
      calculateArray: [],
      paymentNumObj: {
        'pf': 5,
        'pt': 10,
        'pfif': 15,
        'pytw': 20,
        'pOne': 1,
        'pfo': 4,
        'pn': 9,
        'pfot': 14,
        'pnt': 19
      },
      healthInsurance: 'T',
      occupationType: '2',
      coverName: '',
      coverTitle: '',
      clauseShow: false,
      clauseData: [],
      rateShow: false,
      ruleShow: false
    }
  },
  mounted () {
    document.title = '鼎诚人寿'
    for (let i = 0; i < 66; i++) {
      this.ageInsuredArray.push(i)
    }
    for (let i = 18; i < 61; i++) {
      this.agePolicyArray.push(i)
    }
    this.startInsuredDate = new Date().getFullYear() - 66 + '/' + (new Date().getMonth() + 1) + '/' + (new Date().getDate() + 1)
    this.endInsuredDate = new Date().getFullYear() + '/' + (new Date().getMonth() + 1) + '/' + (new Date().getDate())
    this.startPolicyDate = new Date().getFullYear() - 61 + '/' + (new Date().getMonth() + 1) + '/' + (new Date().getDate() + 1)
    this.endPolicyDate = new Date().getFullYear() - 18 + '/' + (new Date().getMonth() + 1) + '/' + new Date().getDate()
    this.setPolOption()
    window.sessionStorage.setItem('cAge', '18')
    document.getElementsByTagName('body')[0].style.backgroundColor = '#ececec'
  },
  methods: {
    async setPolOption () {
      await this.getAllPolInfo()
      this.getInsuredPolInfo()
    },
    getInsureSex (sex) {
      this.cSex = sex
      this.getInsuredPolInfo()
    },
    getInsureAge (age) {
      this.cAge = age
      this.pCheckDisable = age < 18
      if (this.pCheckDisable) {
        this.pCheck = true
        this.showPolicyInfo = true
      }
      sessionStorage.setItem('cAge', this.cAge)
      this.getInsuredPolInfo()
    },
    getPolicySex (sex) {
      this.pSex = sex
    },
    getPolicyAge (age) {
      this.pAge = age
    },
    getPolicyInfoChecked (checked) {
      this.pCheck = checked
      if (checked) {
        this.showPolicyInfo = true
        this.policyHeadDesc = '投保人信息(豁免相关)'
      } else {
        this.showPolicyInfo = false
        this.policyHeadDesc = '投保人信息(豁免相关)'
      }
      this.getInsuredPolInfo()
    },
    // 获取所有险种可选必选关系，若为必选则选择完做保费计算
    getAllPolInfo () {
      return new Promise((resolve) => {
        axios.get('controller/insuranceTypeChoose/defaultList', {
          params: {
            productId: 'PID0002'
          }
        }).then((data) => {
          this.allPolInfoData = data.data
          for (let item of data.data) {
            this.clauseData.push({
              pid: item.pid,
              pName: item.pid === 'P0007' ? '鼎康宝终身重大疾病险' : item.pname
            })
            if (item.pid === 'P0007') {
              this.clauseData.push(
                {
                  pid: 'P0016',
                  pName: '鼎康宝定期重大疾病险(A款)'
                },
                {
                  pid: 'P0018',
                  pName: '鼎康宝定期重大疾病险(B款)'
                })
            }
          }
          resolve(data)
        })
      })
    },
    // 获取被保人默认险种信息
    getInsuredPolInfo () {
      let exemption
      if (this.pCheck) {
        exemption = 'F'
      } else {
        exemption = 'T'
      }
      let cAge = Number(this.cAge)
      if (cAge <= 60 && cAge > 55) {
        this.paymentPeriod = 'pf'
      } else if (cAge <= 55 && cAge > 50) {
        this.paymentPeriod = 'pf'
      } else if (cAge <= 50 && cAge > 45) {
        this.paymentPeriod = 'pt'
      } else if (cAge <= 45 && cAge > 40) {
        this.paymentPeriod = 'pfif'
      }
      if (cAge <= 60) {
        axios.get('/controller/insuranceTypeChoose/list', {
          params: {
            cAge: cAge,
            exemption: exemption,
            medicalInsurance: this.healthInsurance,
            paymentPeriod: this.paymentPeriod,
            occupationCategory: this.occupationType,
            productId: 'PID0002'
          }
        }).then((data) => {
          let resData = data.data
          let allPolInfoData = JSON.parse(JSON.stringify(this.allPolInfoData))
          if (this.usePolInfo) {
            for (let useItem of this.usePolInfo) {
              // useItem.paymentPeriod = this.getUsePaymentPeriod(useItem.paymentPeriod, useItem.pid)
              if (useItem.pid !== 'P0007' && useItem.pid !== 'P0008') {
                useItem.paymentPeriod = 'pOne'
              } else {
                useItem.paymentPeriod = this.getUsePaymentPeriod(useItem.paymentPeriod, useItem.pid, useItem.expiration)
              }
              if (useItem.pid === 'P0013' || useItem.pid === 'P0014') {
                let guaranteeTypeNum
                if (useItem.guaranteeType === '1') {
                  guaranteeTypeNum = 90400
                }
                if (useItem.guaranteeType === '2') {
                  guaranteeTypeNum = 177200
                }
                if (useItem.guaranteeType === '3') {
                  guaranteeTypeNum = 349000
                }
                useItem.premium = guaranteeTypeNum * this.paymentNumObj[useItem.paymentPeriod]
              }
              if (useItem.pid === 'P0011' || useItem.pid === 'P0015') {
                useItem.premium = useItem.quota * this.paymentNumObj[useItem.paymentPeriod]
              }
              let hasPol = false
              for (let item of resData) {
                if (item.pid === useItem.pid) {
                  hasPol = true
                  break
                }
              }
              if (!hasPol && useItem.type !== 'require') {
                useItem.check = false
                useItem.checked = false
                useItem.select = false
                useItem.checkDisabled = 'unCheckDisabled'
              } else {
                if (useItem.type !== 'require') {
                  useItem.check = true
                  useItem.checkDisabled = undefined
                  if ((useItem.pid === 'P0011' || useItem.pid === 'P0015') && (this.occupationType === '5' || this.occupationType === '6')) {
                    useItem.check = false
                    useItem.checked = false
                    useItem.select = false
                    useItem.checkDisabled = 'unCheckDisabled'
                  }
                }
              }
            }
            for (let item of this.usePolInfo) {
              if (item.pid === 'P0007' && item.paymentPeriod === 'pw') {
                for (let item2 of this.usePolInfo) {
                  if (item2.pid === 'P0008') {
                    item2.check = false
                    item2.checked = false
                    item2.checkDisabled = 'unCheckDisabled'
                  }
                }
              }
            }
          } else {
            for (let item of allPolInfoData) {
              item.premium = 300000
              if (item.pid !== 'P0007' && item.pid !== 'P0008') {
                item.paymentPeriod = 'pOne'
              } else {
                if (item.pid !== 'P0008') {
                  item.paymentPeriod = this.paymentPeriod
                } else {
                  switch (this.paymentPeriod) {
                    case 'pf':
                      item.paymentPeriod = 'pfo'
                      break
                    case 'pt':
                      item.paymentPeriod = 'pn'
                      break
                    case 'pfif':
                      item.paymentPeriod = 'pfot'
                      break
                    case 'pytw':
                      item.paymentPeriod = 'pnt'
                  }
                }
              }
              if (item.pid === 'P0007') {
                item.expiration = 'all'
              }
              if (item.pid === 'P0013' || item.pid === 'P0014') {
                item.guaranteeType = '1'
                let guaranteeTypeNum
                if (item.guaranteeType === '1') {
                  guaranteeTypeNum = 90400
                }
                if (item.guaranteeType === '2') {
                  guaranteeTypeNum = 177200
                }
                if (item.guaranteeType === '3') {
                  guaranteeTypeNum = 349000
                }
                item.premium = guaranteeTypeNum * this.paymentNumObj[item.paymentPeriod]
              }
              if (item.pid === 'P0011' || item.pid === 'P0015') {
                item.quota = 10000
                item.premium = item.quota * this.paymentNumObj[item.paymentPeriod]
              }
              if (item.pid === 'P0010') {
                item.transportListData = [{
                  name: '汽车',
                  val: 'car',
                  premium: 300000
                }]
              }
              if (item.pid === 'P0012') {
                item.counts = 30
                item.premium = this.paymentNumObj[this.paymentPeriod] * item.counts * 10
              }
              if (item.type === 'require') {
                item.check = true
                item.checked = true
                item.checkDisabled = 'checkDisabled'
              }
              for (let item2 of resData) {
                if (item.pid === item2.pid) {
                  item.pPid = item2.pPid
                  item.check = true
                  item.checked = true
                  item.select = true
                  if ((item.pid === 'P0011' || item.pid === 'P0015') && (this.occupationType === '5' || this.occupationType === '6')) {
                    item.check = false
                    item.checked = false
                    item.select = false
                    item.checkDisabled = 'unCheckDisabled'
                  }
                }
              }
            }
            for (let item of allPolInfoData) {
              if (!item.check) {
                item.check = false
                item.checked = false
                item.checkDisabled = 'unCheckDisabled'
                item.select = false
              }
            }
            this.usePolInfo = allPolInfoData
          }
          this.polReset = false
          this.$nextTick(() => {
            this.polReset = true
          })
          this.getPremium()
        })
      } else {
        let allPolInfoData = JSON.parse(JSON.stringify(this.allPolInfoData))
        let usePolInfo = JSON.parse(JSON.stringify(this.usePolInfo))
        this.usePolInfo = []
        for (let item of allPolInfoData) {
          item.premium = 300000
          if (item.pid === 'P0007' || item.pid === 'P0008' || item.pid === 'P0017') {
            item.check = true
            item.checked = true
            item.checkDisabled = undefined
            if (item.pid === 'P0007') {
              item.expiration = 'dateB10'
              item.paymentPeriod = 'pt'
              item.checkDisabled = 'checkDisabled'
            } else if (item.pid === 'P0008') {
              item.expiration = 'dateB10'
              item.paymentPeriod = 'pn'
            } else if (item.pid === 'P0017') {
              item.paymentPeriod = 'pOne'
            }
          } else {
            item.check = false
            item.checked = false
            item.checkDisabled = 'unCheckDisabled'
            item.paymentPeriod = 'pOne'
            if (item.pid === 'P0013' || item.pid === 'P0014') {
              for (let guaranteeTypeItem of usePolInfo) {
                if (item.pid === guaranteeTypeItem.pid) {
                  item.guaranteeType = guaranteeTypeItem.guaranteeType
                  let guaranteeTypeNum
                  if (item.guaranteeType === '1') {
                    guaranteeTypeNum = 90400
                  }
                  if (item.guaranteeType === '2') {
                    guaranteeTypeNum = 177200
                  }
                  if (item.guaranteeType === '3') {
                    guaranteeTypeNum = 349000
                  }
                  item.premium = guaranteeTypeNum * this.paymentNumObj[guaranteeTypeItem.paymentPeriod]
                  item.paymentPeriod = guaranteeTypeItem.paymentPeriod
                }
              }
            }
            if (item.pid === 'P0011' || item.pid === 'P0015') {
              for (let quotaItem of usePolInfo) {
                if (item.pid === quotaItem.pid) {
                  item.quota = quotaItem.quota
                  item.premium = item.quota * this.paymentNumObj[quotaItem.paymentPeriod]
                  item.paymentPeriod = quotaItem.paymentPeriod
                }
              }
            }
            if (item.pid === 'P0010') {
              for (let transportItem of usePolInfo) {
                if (item.pid === transportItem.pid) {
                  item.transportListData = transportItem.transportListData
                }
              }
            }
            if (item.pid === 'P0012') {
              for (let countsItem of usePolInfo) {
                if (item.pid === countsItem.pid) {
                  item.counts = countsItem.counts
                  item.premium = this.paymentNumObj[this.paymentPeriod] * item.counts * 10
                }
              }
            }
          }
          this.usePolInfo.push(item)
        }
        this.polReset = false
        this.$nextTick(() => {
          this.polReset = true
        })
        this.getPremium()
      }
    },
    // 判断险种是否在可选险种中
    isPolOptional (pid, data) {
      let res = false
      for (var i = 0; i < data.length; i++) {
        if (data[i].pid === pid) {
          return true
        }
      }
      return res
    },
    // 选择合适的交费期间
    getUsePaymentPeriod (paymentPeriod, pid) {
      let age = Number(this.cAge)
      let periodYearObj = {
        'pw': 0,
        'pOne': 1,
        'pf': 5,
        'pt': 10,
        'pfif': 15,
        'pytw': 20,
        'pfo': 4,
        'pn': 9,
        'pfot': 14,
        'pnt': 19
      }
      let xNum = age + periodYearObj[paymentPeriod]
      let expiration = this.usePolInfo[0].expiration
      if (expiration === 'all') {
        let agePaymentPeriodArray = ['pfif', 'pytw', 'pfot', 'pnt']
        let agePaymentPeriodArray2 = ['pfif', 'pytw', 'pfot', 'pnt', 'pt', 'pn']
        if (age <= 50) {
          return paymentPeriod
        } else if (age > 50 && age <= 55) {
          if (agePaymentPeriodArray.indexOf(paymentPeriod) >= 0) {
            if (pid === 'P0008') {
              return 'pn'
            } else {
              return 'pt'
            }
          } else {
            return paymentPeriod
          }
        } else if (age > 55 && age <= 60) {
          if (agePaymentPeriodArray2.indexOf(paymentPeriod) >= 0) {
            if (pid === 'P0008') {
              return 'pfo'
            } else {
              return 'pf'
            }
          } else {
            return paymentPeriod
          }
        }
      } else if (expiration === 'age70' || expiration === 'age80' || expiration === 'date20' || expiration === 'date30') {
        if (xNum <= 60) {
          return paymentPeriod
        } else if (age <= 60 && age > 55) {
          if (pid === 'P0008') {
            return paymentPeriod
          } else {
            return 'pw'
          }
        } else if (age <= 55 && age > 50) {
          if (pid === 'P0008') {
            return 'pfo'
          } else {
            return 'pf'
          }
        } else if (age <= 50 && age > 45) {
          if (pid === 'P0008') {
            return 'pn'
          } else {
            return 'pt'
          }
        } else if (age <= 45 && age > 40) {
          if (pid === 'P0008') {
            return 'pfot'
          } else {
            return 'pfif'
          }
        } else if (age <= 40) {
          if (pid === 'P0008') {
            return 'pnt'
          } else {
            return 'pytw'
          }
        }
      } else {
        if (xNum <= 75) {
          return paymentPeriod
        } else if (age <= 60 && age > 55) {
          if (expiration !== 'dateB10') {
            if (pid === 'P0008') {
              return 'pfot'
            } else {
              return 'pfif'
            }
          } else {
            if (pid === 'P0008') {
              return 'pn'
            } else {
              return 'pt'
            }
          }
        } else if (age <= 55 && age > 45) {
          if (expiration === 'dateB10') {
            if (pid === 'P0008') {
              return 'pn'
            } else {
              return 'pt'
            }
          } else if (expiration === 'dateB15') {
            if (pid === 'P0008') {
              return 'pfot'
            } else {
              return 'pfif'
            }
          } else if (expiration === 'dateB20') {
            if (pid === 'P0008') {
              return 'pnt'
            } else {
              return 'pytw'
            }
          } else if (expiration === 'dateB30') {
            if (pid === 'P0008') {
              return 'pnt'
            } else {
              return 'pytw'
            }
          }
        } else if (age <= 45) {
          if (expiration === 'dateB10') {
            if (pid === 'P0008') {
              return 'pn'
            } else {
              return 'pt'
            }
          } else if (expiration === 'dateB15') {
            if (pid === 'P0008') {
              return 'pfot'
            } else {
              return 'pfif'
            }
          } else if (expiration === 'dateB20') {
            if (pid === 'P0008') {
              return 'pnt'
            } else {
              return 'pytw'
            }
          } else if (expiration === 'dateB30') {
            if (pid === 'P0008') {
              return 'ptnt'
            } else {
              return 'ptt'
            }
          }
        }
      }
    },
    getPremium () {
      // 重新定义保费计算
      let calculateArray = []
      for (let item of this.usePolInfo) {
        let insuredCustomer = {
          sex: item.pid === 'P0008' ? this.pSex : this.cSex,
          age: item.pid === 'P0008' ? this.pAge : this.cAge,
          birthday: null,
          phone: null,
          carId: null,
          carType: null,
          occupationType: this.occupationType,
          healthInsurance: this.healthInsurance
        }
        if (item.type === 'require' || (item.check && item.checked)) {
          if (item.pid === 'P0010') {
            for (let pItem of item.transportListData) {
              calculateArray.push({
                pid: item.pid,
                calculateType: item.calculateType,
                premium: pItem.premium,
                counts: 0,
                paymentPeriod: 'pOne',
                transportList: [pItem.val],
                guaranteeType: null,
                quota: null,
                expiration: null,
                pName: item.pname,
                insuredCustomer: insuredCustomer
              })
            }
          } else {
            calculateArray.push({
              pid: item.pid,
              calculateType: item.calculateType,
              premium: item.pid === 'P0012' ? 0 : item.premium,
              counts: item.counts || 0,
              paymentPeriod: (item.pid === 'P0008' || item.pid === 'P0007') ? item.paymentPeriod : 'pOne',
              transportList: null,
              guaranteeType: item.guaranteeType || null,
              quota: item.quota || null,
              expiration: item.expiration || null,
              pName: item.pname,
              insuredCustomer: insuredCustomer
            })
          }
        }
      }
      // console.log(JSON.stringify({
      //   insuranceTypeList: calculateArray
      // }))
      axios({
        url: '/controller/insuranceTypeChoose/premuimCalculate',
        method: 'post',
        data: {
          insuranceTypeList: calculateArray
        }
      }).then((data) => {
        this.calculateObj = {
          insuranceTypeList: calculateArray
        }
        // data.data.insuranceTypes = data.data.insuranceTypes.sort(function (a, b) {
        //   return Number(a.pid.substr(1, a.length)) - Number(b.pid.substr(1, b.length))
        // })
        this.polTableData = data.data
      })
    },
    getCheckStatus (status, index, pid) {
      let usePolInfoItem = this.usePolInfo[index]
      usePolInfoItem.checked = status
      this.$set(this.usePolInfo, index, usePolInfoItem)
      // if (pid === 'P0009') {
      //   for (let i = 0; i < this.usePolInfo.length; i++) {
      //     if (this.usePolInfo[i].pid === 'P0011' || this.usePolInfo[i].pid === 'P0012' || this.usePolInfo[i].pid === 'P0013' || this.usePolInfo[i].pid === 'P0014' || this.usePolInfo[i].pid === 'P0015') {
      //       let item = this.usePolInfo[i]
      //       if (item.check) {
      //         item.checked = status
      //         // item.check = status
      //         if (status) {
      //           item.checkDisabled = false
      //         } else {
      //           item.checkDisabled = 'unCheckDisabled'
      //         }
      //         this.$set(this.usePolInfo, i, item)
      //       }
      //     }
      //   }
      // }
    },
    changePaymentPeriod (data) {
      this.paymentPeriod = data
    },
    getHealthInsurance (data) {
      this.healthInsurance = data
      this.getInsuredPolInfo()
    },
    getOcc (des, val) {
      this.occupationType = val
    },
    gotoShowPlan () {
      let premium = this.polTableData.sum
      let insuranceTypeList = []
      for (let item of this.polTableData.insuranceTypes) {
        insuranceTypeList.push({
          prospectusId: null,
          pid: item.pid,
          pName: item.pName,
          paymentPeriod: `${this.paymentPeriodObj[item.paymentPeriod]}`,
          insurancePeriod: this.usePolInfo[0].expiration,
          insuredAmount: item.insuredAmount,
          premium: item.premium,
          transport: item.transport
        })
      }
      Indicator.open({
        text: '请稍等...',
        spinnerType: 'fading-circle'
      })
      axios({
        url: '/controller/prospectus/creatPropectus',
        method: 'post',
        data: {
          prospectusId: null,
          insure: {
            age: this.cAge,
            sex: this.cSex,
            name: null
          },
          holder: {
            age: this.pCheck ? this.pAge : this.cAge,
            sex: this.pCheck ? this.pSex : this.cSex,
            name: null
          },
          premium: premium,
          productId: 'PID0002',
          insuranceTypeList: insuranceTypeList
        }
      }).then(data => {
        Indicator.close()
        if (this.coverCheck) {
          window.location.href = `${window.origin}/#/showPlan?prospectusId=${data.data}&name=${this.coverName}&sex=${this.coverSex}&title=${this.coverTitle}`
          // this.$router.push({
          //   name: 'showPlan',
          //   query: {
          //     prospectusId: data.data,
          //     name: this.coverName,
          //     sex: this.coverSex,
          //     title: this.coverTitle
          //   }
          // })
        } else {
          window.location.href = `${window.origin}/#/showPlan?prospectusId=${data.data}`
          // this.$router.push({
          //   name: 'showPlan',
          //   query: {
          //     prospectusId: data.data
          //   }
          // })
        }
      })
    },
    getCoverInfoChecked (checked) {
      this.coverCheck = checked
      this.showCoverInfo = checked
    },
    getCoverSex (sex) {
      this.coverSex = sex
    },
    getCoverName (name) {
      this.coverName = name
    },
    getCoverTitle (title) {
      this.coverTitle = title
    },
    showClause () {
      this.clauseShow = true
    },
    getClauseStatus (data) {
      this.clauseShow = data
    },
    showRate () {
      this.rateShow = true
    },
    getRateStatus (data) {
      this.rateShow = data
    },
    getRuleStatus (data) {
      this.ruleShow = data
    },
    showRule () {
      this.ruleShow = true
    }
  },
  watch: {
    occupationType () {
      this.getInsuredPolInfo()
    }
  }
}
</script>

<style scoped>
  #makePlan {
    padding-bottom: 70px;
  }
  .insureInfo, .polSelect{
    width: 95%;
    overflow: hidden;
    margin: 10px auto 0 auto;
    border-radius: 5px;
    background-color: #ffffff;
    padding: 10px 0;
  }
  .coverInfo {
    width: 95%;
    overflow: hidden;
    margin: 10px auto 0 auto;
    border-radius: 5px;
    background-color: #ffffff;
    padding: 10px 0;
  }
  .otherInfo {
    width: 95%;
    overflow: hidden;
    margin: 10px auto 0 auto;
    border-radius: 5px;
    background-color: #ffffff;
    padding: 10px 0;
    display: flex;
    justify-content: space-around;
  }
  .otherInfoContent {
    width: 70px;
    position: relative;
    text-align: center;
  }
  .otherInfoContent span {
    font-size: 14px;
    display: inline-block;
    padding: 5px 0;
  }
  .iconContent {
    width: 50px;
    height: 50px;
    margin-left: 10px;
    border: 1px solid #167bff;
    border-radius: 50%;
    position: relative;
  }
  .otherInfoFont {
    font-size: 30px;
    color: #167bff;
    position: absolute;
    left: 10px;
    top: 10px;
  }
  .bottom {
    z-index: 90;
    position: fixed;
    left: 0;
    bottom: 0;
    width: 100%;
    background-color: #f8f8f8;
    text-align: center;
    height: 60px;
  }
  .premuimCount {
    padding: 0 15px;
    height: 100%;
    text-align: left;
  }
  .premuimCountDesc {
    font-size: 14px;
    line-height: 30px;
    color: #676767;
  }
  .premuimCountNum {
    color: #e58800;
    font-size: 24px;
    line-height: 20px;
  }
  .premuimCountNumSmall {
    font-size: 12px;
  }
  .buildPlan {
    height: 46px;
    line-height: 46px;
    padding: 0 15px;
    background-color: #167bff;
    color: #ffffff;
    font-size: 16px;
    position: absolute;
    right: 15px;
    top: 7px;
    border-radius: 5px;
  }
  .textContainer {
    padding: 5px 15px;
    font-size: 14px;
    position: relative;
    color: #535353;
    line-height: 27px;
  }
  .inputContainer {
    right: 15px;
    position: absolute;
    top: 0;
  }
</style>
